home *** CD-ROM | disk | FTP | other *** search
/ Computer Inter@ctive 17 / Computer Interactive cdrom 17 - gen 99.iso / ZDNETIT / CONTENT / SMTPCEMS.ZIP / MULTI.C < prev    next >
Encoding:
C/C++ Source or Header  |  1998-11-15  |  2.1 KB  |  66 lines

  1. /*
  2. **  MULTI.C [edit EMAIL.H before compiling].
  3. ** 
  4. **  This program emails two messages, including a
  5. **  MIME attachment.
  6. */
  7.  
  8. // IMPORTANT: edit these definitions before compiling 
  9. #include "email.h"
  10. #define FIRST_SEND_TO   "1st receipient's email address"
  11. #define SECOND_SEND_TO  "2nd receipient's email address"
  12.  
  13. #include <windows.h>
  14. #include <stdio.h>
  15. #include "see.h"
  16.  
  17. static char Buffer[512];
  18.  
  19. void ErrorExit(int Code)
  20. {seeErrorText(Code,(LPSTR)Buffer,512);
  21.  printf("%s\n", Buffer);
  22.  exit(0);
  23. }
  24.  
  25. /*** main ***/
  26.  
  27. void main(void)
  28. {int Code; 
  29.  /* define diagnostics log file */
  30.  ///seeStringParam(SEE_LOG_FILE, (LPSTR)"multi.log"); 
  31.  /* connect to SMTP server */
  32.  puts("Connecting...");
  33.  Code = seeSmtpConnect(
  34.     (LPSTR)SMTP_HOST_NAME,                     /* SMTP server */
  35.     (LPSTR)YOUR_EMAIL_ADDR,                    /* our return email address */
  36.     (LPSTR)NULL);                              /* Reply-To header */
  37.  if(Code<0) ErrorExit(Code);
  38.   
  39.  /* send first email */
  40.  puts("Sending email #1 ...");
  41.  Code = seeSendEmail(
  42.     (LPSTR)FIRST_SEND_TO,                      /* To list */
  43.     (LPSTR)NULL,                               /* CC list */
  44.     (LPSTR)NULL,                               /* BCC list */
  45.     (LPSTR)"MULTI Example Program",            /* subject */
  46.     (LPSTR)"Hello from MULTI.C !!!\r\nBye!",   /* text message */
  47.     (LPSTR)NULL);                              /* no attachment */                
  48.  if(Code<0) ErrorExit(Code); 
  49.  
  50.  /* send second email */  
  51.  puts("Sending email #2 ...");
  52.  Code = seeSendEmail(
  53.     (LPSTR)SECOND_SEND_TO,                     /* To list */
  54.     (LPSTR)NULL,                               /* CC list */
  55.     (LPSTR)NULL,                               /* BCC list */    
  56.     (LPSTR)"MULTI Example Program",            /* subject */
  57.     (LPSTR)"@test.mai",                        /* message in file */
  58.     (LPSTR)"test.zip");                        /* attachment (size will be multiple of 4) */                
  59.  if(Code<0) ErrorExit(Code);
  60.  puts("Closing...");
  61.  Code = seeClose();
  62.  if(Code<0) ErrorExit(Code);
  63. } /* end main */
  64.  
  65.  
  66.